package net.socket;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class EchoClient
{
	public static void main(String[] args)
	{
		String hostname = "localhost";
		PrintWriter out = null;
		BufferedReader networkIn = null;
		try
		{
			Socket theSocket = new Socket(hostname, 7);
			networkIn = new BufferedReader(new InputStreamReader(theSocket.getInputStream()));
			BufferedReader userIn = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(theSocket.getOutputStream());
			while (true)
			{
				String theLine = userIn.readLine();
				if (theLine.equals("."))
				{
					break;
				}
				out.println(theLine);
				out.flush();
				System.out.println(networkIn.readLine());
			}
		}
		catch (Exception e)
		{
		}
		finally
		{
			try
			{
				if (networkIn != null)
				{
					networkIn.close();
				}
				if (out != null)
				{
					out.close();
				}
			}
			catch (Exception e2)
			{
			}
		}
	}
}
